package org.example.booksystem.config;

import org.example.booksystem.moudel.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ResponseBody
@ControllerAdvice
public class ErrorHandler {

     @ExceptionHandler
    public Result handler(Exception e){
         return Result.fail("发生错误,请联系管理员");
     }

     @ExceptionHandler
    public Result handler(NullPointerException e){
         return Result.fail("发生NullPointerException异常") ;
     }


}
